﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using WEBWeixinSDK;

namespace WxLogin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            SysLog.GetInstance().NewLogWrite += Form1_NewLogWrite;
            CheckForIllegalCrossThreadCalls = false;
        }
       public  int namenum = 1;
        private void Form1_NewLogWrite(object sender, CQLogEventArgs e)
        {
            txtlog.Text += e.LogMessage.ToString() + "\r\n";
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            Image imstr = WEBWeixinSDK.Weixin.Getjslogin();
            if (imstr != null)
            {
                this.pictureBox1.Image = imstr;
            }
            namenum++;
        }

        private void Button2_Click(object sender, EventArgs e)
        {
          
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
            Image imstr = WEBWeixinSDK.Weixin.Getjslogin();
            if (imstr != null)
            {
                this.pictureBox1.Image = imstr;
            }
            Weixin.BELoginStatus(this, LoginStatus);
            Thread thread = new Thread(Weixin.Get_UserLogin);
            thread.Start();

          
        }
        public void LoginStatus(Weixin .LoginStatus status)
        {
            switch (status)
            {
                case Weixin.LoginStatus.LoginSuccess:
                    TabMainForm tab = new TabMainForm();

                    tab.AddTabControl("账号","", new MainL());
                    this.Hide();
                    tab.Show();
                    break;

            }
        }


    }
}
